package com.yunji.aggregate.model.dto.stock;

import com.yunji.common.base.PageDTO;
import com.yunji.common.enums.business.StatsType;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;

import java.time.LocalDateTime;

/**
 * @Project: yunji-coffee
 * @Package: com.yunji.user.params
 * @Title: DateParam
 * <p>
 * History:
 * Date                     Version     Author          Summary
 * ============================================================
 * 2024-09-27 16:20:22      V1.0        HuaAo       新建类
 */
@EqualsAndHashCode(callSuper = true)
@Data
public class StatisticsDataParam extends PageDTO {

    @ApiModelProperty("所属ID")
    private Long belongId;

    @ApiModelProperty("父级所属ID")
    private Long parentId;

    @ApiModelProperty("商品类型")
    private Integer productType;

    @ApiModelProperty("交易类型")
    private Integer tradeType;

    @ApiModelProperty("代理商Ids")
    private Long[] agentIds;

    @ApiModelProperty("网点Ids")
    private Long[] siteIds;

    @ApiModelProperty("提点方式 0:不分成;1:按金额比例;2:按固定金额; 默认:0关闭")
    private Integer scaleType;

    @ApiModelProperty("合作方式 0-代理合作 1-自营")
    private Integer cooperateWay;

    @ApiModelProperty("网点类型Ids")
    private Integer[] siteTypeIds;

    @ApiModelProperty("商品Ids")
    private Long[] productIds;

    @ApiModelProperty("货柜Ids")
    private Long[] containerIds;

    @ApiModelProperty("用户类型")
    private String userType;

    @ApiModelProperty("货柜类型")
    private Integer containerType;

    @ApiModelProperty("货柜外形")
    private Integer containerShape;

    @ApiModelProperty(value = "统计类型 0-按天统计 1-按月统计 2-按年统计", required = true)
    private Integer statsType;

    @ApiModelProperty("开始时间")
    private String beginDay;

    @ApiModelProperty("结束时间")
    private String closeDay;

    @ApiModelProperty("最小时间")
    private LocalDateTime minTime;

    @ApiModelProperty("最大时间")
    private LocalDateTime maxTime;

    @ApiModelProperty("网点数排序 0-正序 1-倒序")
    private Integer siteNumsOrder;

    @ApiModelProperty("员工数排序 0-正序 1-倒序")
    private Integer staffNumsOrder;

    @ApiModelProperty("货柜数排序 0-正序 1-倒序")
    private Integer containerNumsOrder;

    @ApiModelProperty("成交笔数排序 0-正序 1-倒序")
    private Integer orderNumsOrder;

    @ApiModelProperty("销售金额排序 0-正序 1-倒序")
    private Integer orderAmountOrder;

    @ApiModelProperty("佣金收益排序 0-正序 1-倒序")
    private Integer earnAmountOrder;

    @ApiModelProperty("分润比例排序 0-正序 1-正序")
    private Integer scaleOrder;

    @ApiModelProperty(hidden = true)
    private boolean shortStr = false;

    public String getTimeQueryType() {
        if (this.getStatsType() != null) {
            if (this.getStatsType().equals(StatsType.MONTH.getCode())) {
                return "%Y-%m";
            } else if (this.getStatsType().equals(StatsType.YEAR.getCode())) {
                return "%Y";
            }
        }
        return shortStr ? "%m-%d" : "%Y-%m-%d";
    }

}